<template>
  <div class="app-container">
    <el-table v-loading="loading" :data="postList">
      <el-table-column label="项目小组" align="center" prop="projectGroupsName" />
      <el-table-column label="岗位编号" align="center" prop="projectPostNo" />
      <el-table-column label="岗位名称" align="center" prop="projectPostName" />
      <el-table-column label="职务" align="center" prop="projectDuitsName" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" @click="handleSelected(scope.row)">选择</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>

export default {
  name: "addWorkPlan",
  props: {
    projectId: {
      type: Number
    },
    notPostIds: {
      type: Array
    }
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 项目岗位
      postList: [],

    };
  },
  created() {
    this.getList();
  },
  methods: {
    // 根据项目id查询该项目下岗位列表 带岗位ids过滤条件
    getList() {
      this.loading = false;
      getProjectPostList({
        projectId: this.projectId,
        params: {
          notPostIds: this.notPostIds
        }
      }).then(res => {
        this.loading = false;
        this.postList = res.data;
      })
    },
    // 岗位选择
    handleSelected(row) {
      this.$emit('select', row);
    }
  }
};
</script>